<?php
	session_start();
	if(isset($_SESSION['ADMIN']))
	{
		header('Location:admin_master_page.php');
		exit;
	}
	include_once('libs/htdu_core.php');
	@$username = $_POST['username'];
	@$password = $_POST['password'];
	$show_msg = false;
	if(isset($username) && isset($password))
	{
		$security = new security();
		$exec_mysql = new execute_mysql_query();
		$pass = $exec_mysql->execute("select val from extra where ref = 'admin_pass'", 1);
		if($pass == $security->encryption($password) && $username == 'admin')
		{
			$_SESSION['ADMIN'] = 'LOGEDIN';
			header('Location:admin_master_page.php');
			exit;
		}
		else
		{
			$show_msg = true;
		}
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Đăng nhập - DKT Group Website Manager System</title>
        <script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
        <link rel="stylesheet" type="text/css" href="css/control.css" />
        <style type="text/css">
        	html, body
			{
				font-family:Arial, Helvetica, sans-serif;
				font-size:14px;
				line-height:20px;
				background-image:url(img/bg.png);
				margin:0px;
			}
			
			.login-panel
			{
				position:absolute;
				width:328px;
				left:50%;
				margin-left:-164px;
				top:50%;
				margin-top:-106px;
			}
			
			.header-panel
			{
				width:100%;
				height:57px;
				background-image:url(img/login_form_top.png);
				text-align:center;
				line-height:57px;
			}
			
			.body-panel
			{
				width:100%;
				background-image:url(img/login_form_middle.png);
			}
			
			.footer-panel
			{
				width:100%;
				height:18px;
				background-image:url(img/login_form_bottom.png);
			}
			
			.btn-submit
			{
				width:202px;
				height:37px;
				background-image:url(img/btn_login.png);
				border:0px;
				text-shadow: 0px 0px 2px #363535;
				color:#ffffff;
				font-weight:bold;
			}
			
			.btn-submit:active
			{
				background-image:url(img/btn_login_press.png);
			}
			
			.span-header
			{
				background-image: url(img/ico_login.png);
				background-repeat: no-repeat;
				background-position: left;
				padding: 10px 5px 10px 35px;
				font-weight: bold;
				font-size: 18px;
				color: #696e7a;
				text-shadow: 0px 1px 0px #f3f7fe;
			}
			
			.span-copy
			{
				position:absolute;
				bottom:0px;
				padding-bottom:10px;
				left:50%;
				margin-left:-183px;
			}
			
			.error-message
			{
				position:absolute;
				background-color:#bd1b1b;
				margin-top:10px;
				padding:5px;
				border-radius:3px;
				left:50%;
				margin-left:-133px;
				color:#ffffff;
				display:none;
			}
        </style>
        <script type="text/javascript">
        	function showError(){
				$(document).ready(function(e) {
                    $('#msg-err').fadeIn(300).delay(5000).fadeOut(300);
                });
			}
        </script>
    </head>
    <?php
    	if($show_msg)
		{
			echo '<script type="text/javascript">showError();</script>';
		}
	?>
    <body>
    	<span class="error-message" id="msg-err">Tên đăng nhập và mật khẩu không đúng</span>
    	<div class="login-panel">
        	<div class="header-panel"><span class="span-header">Đăng nhập quản trị</span></div>
            <div class="body-panel">
            	<form method="post" >
                    <table class="form-layout" align="center">
                        <tr>
                            <td>Tên đăng nhập</td>
                            <td><input type="text" name="username" /></td>
                        </tr>
                        <tr>
                            <td>Mật khẩu</td>
                            <td><input type="password" name="password" /></td>
                        </tr>
                        <tr height="50" valign="bottom">
                            <td colspan="2" align="center"><button type="submit" class="btn-submit">ĐĂNG NHẬP</button></td>
                        </tr>
                    </table>
                </form>
            </div>
            <div class="footer-panel"></div>
        </div>
        <span class="span-copy">Copyright &copy; 2013 DKT Group Website Manager System&trade;</span>
    </body>
</html>